package cn.yyh.mq.runner;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = {"queue.foo","queue.bar",},containerFactory="rabbitListenerContainerFactory")
public class Receiver {
	@RabbitHandler
	public void process(Teacher teacher){
		System.out.println("Receiver foo: " + teacher);
	}
	@RabbitHandler
	public void process(Student student) {
		System.out.println("Receiver bar: " + student);
	}
}

@Component
@RabbitListener(queues = {"queue.foo1"},containerFactory="rabbitListenerContainerFactory")
class FanoutReceiver1 {
	@RabbitHandler
	public void process(Teacher teacher){
		System.out.println("Receiver foo1: " + teacher);
	}
}

@Component
@RabbitListener(queues = {"queue.foo2"},containerFactory="rabbitListenerContainerFactory")
class FanoutReceiver2 {
	@RabbitHandler
	public void process(Teacher teacher){
		System.out.println("Receiver foo2: " + teacher);
	}
}